/*
 * Copyright (c) Huawei Device Co., Ltd. 2023. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SE_COMMON_EXCEPTION_H
#define SE_COMMON_EXCEPTION_H

#include <stdexcept>
#include <string>

namespace OHOS {
namespace SE {

// matched with HDF SecureElementStatus::SE_NULL_POINTER_ERROR
class NullPointerError : public std::runtime_error {
public:
    NullPointerError(const std::string& what) : runtime_error(what) {}
};

// matched with HDF SecureElementStatus::SE_ILLEGAL_PARAMETER_ERROR
class IllegalArgumentError : public std::runtime_error {
public:
    IllegalArgumentError(const std::string& what) : std::runtime_error(what) {}
};

// matched with HDF SecureElementStatus::SE_ILLEGAL_STATE_ERROR
class IllegalStateError : public std::runtime_error {
public:
    IllegalStateError(const std::string& what) : runtime_error(what) {}
};

// matched with HDF SecureElementStatus::SE_SECURITY_ERROR
class SecurityError : public std::runtime_error {
public:
    SecurityError(const std::string& what) : runtime_error(what) {}
};

// matched with HDF SecureElementStatus::SE_CHANNEL_NOT_AVAILABLE_ERROR
class ChannelNotAvailableError : public std::runtime_error {
public:
    ChannelNotAvailableError(const std::string& what) : runtime_error(what) {}
};

// matched with HDF SecureElementStatus::SE_NO_SUCH_ELEMENT_ERROR
class NoSuchElementError : public std::runtime_error {
public:
    NoSuchElementError(const std::string &what, const std::string &response) : runtime_error(what), response_(response)
    {}
    std::string response_;
};

// matched with HDF SecureElementStatus::SE_ILLEGAL_REFERENCE_ERROR
class IllegalReferenceError : public std::runtime_error {
public:
    IllegalReferenceError(const std::string& what) : runtime_error(what) {}
};

// matched with HDF SecureElementStatus::SE_OPERATION_NOT_SUPPORTED_ERROR
class UnsupportedOperationError : public std::runtime_error {
public:
    UnsupportedOperationError(const std::string &what, const std::string &response)
        : runtime_error(what), response_(response)
    {}
    std::string response_;
};

// matched with HDF SecureElementStatus::SE_IO_ERROR
class IOError : public std::runtime_error {
public:
    IOError(const std::string& what) : runtime_error(what) {}
};

// matched with HDF SecureElementStatus::SE_GENERAL_ERROR
class GeneralError : public std::runtime_error {
public:
    GeneralError(const std::string& what) : runtime_error(what) {}
};

// exception throwed by secure access control module
class AccessControlError : public std::runtime_error {
public:
    AccessControlError(const std::string& what) : std::runtime_error(what) {}
};
}  // namespace SE
}  // namespace OHOS
#endif // SE_COMMON_EXCEPTION_H_
